package com.lst.projectlib.component.CustomView;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewParent;
import android.widget.LinearLayout;

/**
 * Created by sxy on 2017/10/23.
 */

public class LinearLayoutForScrollView extends LinearLayout {
    public LinearLayoutForScrollView(Context context) {
        super(context);
    }

    public LinearLayoutForScrollView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public LinearLayoutForScrollView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public LinearLayoutForScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    //请求其Parents不对Touch进行拦截
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev)
    {
        if (ev.getActionMasked() == MotionEvent.ACTION_DOWN)
        {
            ViewParent p = getParent();
            if (p != null)
                p.requestDisallowInterceptTouchEvent(true);
        }

        return false;
    }

    //给LinearLayout加入Touch事件，使得所有Layout区域的Touch操作均不受拦截
    //参考：http://blog.csdn.net/android_tutor/article/details/7193090
    public boolean onTouchEvent(MotionEvent ev)
    {
        return true;
    }
}
